package com.hd.openapi.servies.serviceimpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hd.openapi.common.ResponseResult;
import com.hd.openapi.common.ResultTable;
import com.hd.openapi.dao.UserTokenMapper;
import com.hd.openapi.entity.UserToken;
import com.hd.openapi.servies.tokenser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class tokenserIML implements tokenser {

    @Autowired
    private UserTokenMapper ut;

    @Override
    public ResultTable gettokendata(Integer page, Integer limit, String accessToken) {
        PageHelper.startPage (page,limit);
        List<UserToken> a=ut.getokendata(accessToken);
        PageInfo aa=new PageInfo (a);
        return new ResultTable (0,"",(int)aa.getTotal (),aa.getList ());
    }

    @Override
    public ResponseResult adddata(UserToken userToken) {
        int i = ut.insertSelective (userToken);
        return ResponseResult.getSuccess ();
    }

    @Override
    public ResponseResult updatada(UserToken userToken) {
        System.out.println (userToken.getAppid ());
        int i = ut.updateByPrimaryKeySelective (userToken);
        return ResponseResult.getSuccess ();
    }

    @Override
    public ResponseResult deldata(Integer[] ids) {
        try {
            int i=ut.deletedata(ids);
            return ResponseResult.getSuccess ("删除成功");
        } catch (Exception e) {
            e.printStackTrace ();
        }
        return ResponseResult.getSuccess ("删除失败");
    }
}
